package com.itheima.tlias84.controller;

import com.alibaba.fastjson2.JSONObject;
import com.itheima.tlias84.utils.ResultUtil;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("session")
/**
 * 服务端
 */
 public class TestSessionController {
     @GetMapping("svae")
    public ResultUtil saveSession(HttpSession session) {
        session.setAttribute("username","liu");
        session.setAttribute("password","123456");

        return ResultUtil.success();
    }
    @GetMapping("/svae")
    public ResultUtil sSession(HttpSession session) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("username",session.getAttribute("liu"));
        jsonObject.put("password",session.getAttribute("123456"));

        return ResultUtil.success();
    }
}
